package com.cq.hd.order.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.order.api.TbOrderApi;
import com.cq.hd.order.api.dto.*;
import com.cq.hd.order.api.pft.PftOrderCallBackParam;
import com.cq.hd.order.api.pft.PftOrderTicketParam;
import com.cq.hd.order.api.vo.*;
import com.cq.hd.order.service.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-12-13
 */
@RestController
public class TbOrderController implements TbOrderApi {

    private static final Logger log = LoggerFactory.getLogger(TbOrderController.class);
    @Autowired
    private TbOrderService orderService;
    @Resource
    private OrderSettleService orderSettleService;
    @Autowired
    private PftService pftService;
    @Resource
    private TbOrderRefundService orderRefundService;
    @Resource
    private TbGroupBuyOrderService groupBuyOrderService;

    @ApiOperation(value = "获取活动红包可用状态")
    @ApiImplicitParam(name = "activeId", value = "活动id", paramType = "body", dataType = "Long")
    @Override
    public Result<Boolean> getRedAvailableStatus(Long activeId, Long userId) {
        return ResultGenerator.success(orderService.getRedAvailableStatus(activeId, userId));
    }

    @ApiOperation(value = "获取用户已下单该活动的数量")
    @ApiImplicitParam(name = "activeId", value = "活动id", paramType = "body", dataType = "Long")
    @Override
    public Result<Integer> getActiveOrderNum(Long activeId, Long userId) {
        return ResultGenerator.success(orderService.getActiveOrderNum(activeId, userId));
    }

    @ApiOperation(value = "我的活动的订单管理的统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "businessId", value = "商家id", paramType = "body", dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户id", paramType = "body", dataType = "Long")
    })
    @ApiResponse(response = ActiveOrderStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<ActiveOrderStatisticsVo> getOrderStatistics(Long businessId, Long userId, Long activeId) {
        return ResultGenerator.success(orderService.getOrderStatistics(businessId, userId, activeId));
    }

    @ApiOperation(value = "创建订单")
    @ApiImplicitParam(name = "createOrderDto", value = "实体", paramType = "body", dataType = "CreateOrderDto")
    @Override
    public Result<CreateOrderVo> createOrder(@RequestBody CreateOrderDto createOrderDto) {
        return ResultGenerator.success(orderService.createOrder(createOrderDto));
    }

    @ApiOperation(value = "创建拼团订单")
    @ApiImplicitParam(name = "createOrderDto", value = "实体", paramType = "body", dataType = "CreateOrderDto")
    @Override
    public Result<CreateOrderVo> createGroupBuyOrder(CreateOrderDto createOrderDto) {
        return ResultGenerator.success(orderService.createGroupBuyOrder(createOrderDto));
    }

    @ApiOperation(value = "创建积分订单")
    @ApiImplicitParam(name = "createOrderDto", value = "实体", paramType = "body", dataType = "CreateOrderDto")
    @Override
    public Result<CreateOrderVo> createPointsOrder(@RequestBody CreateOrderDto createOrderDto) {
        return ResultGenerator.success(orderService.createPointsOrder(createOrderDto));
    }

    @ApiOperation(value = "立即支付，唤起第三方支付")
    @ApiImplicitParam(name = "orderPayDto", value = "实体", paramType = "body", dataType = "OrderPayDto")
    @ApiResponse(response = OrderPayVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<OrderPayVo> pay(@RequestBody OrderPayDto orderPayDto) {
        return ResultGenerator.success(orderService.pay(orderPayDto));
    }

    @ApiOperation(value = "取消支付")
    @ApiImplicitParam(name = "cancelPayDto", value = "实体", paramType = "body", dataType = "CancelPayDto")
    @Override
    public Result<Boolean> cancelPay(@RequestBody CancelPayDto cancelPayDto) {
        return ResultGenerator.success(orderService.cancelPay(cancelPayDto));
    }

    @Override
    public Result<Page<MyPrizeOrderPageVo>> pageMyPrizeOrder(MyPrizePageDto myPrizePageDto) {
        return ResultGenerator.success(orderService.pageMyPrizeOrder(myPrizePageDto));
    }

    @ApiOperation(value = "订单列表（我购买的订单，我卖出的订单，我分销的订单）")
    @ApiResponse(response = AppOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<AppOrderPageVo>> pageAppOrder(AppOrderPageDto appOrderPageDto) {
        return ResultGenerator.success(orderService.pageAppOrder(appOrderPageDto));
    }

    @ApiOperation(value = "订单详情（我购买的订单，我卖出的订单，我分销的订单）")
    @ApiResponse(response = AppOrderDetailVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<AppOrderDetailVo> appOrderDetail(AppOrderDetailDto appOrderDetailDto) {
        return ResultGenerator.success(orderService.appOrderDetail(appOrderDetailDto));
    }

    @Override
    public Result<AppGroupBuyOrderDetailVo> appGroupBuyOrderDetail(AppGroupBuyOrderDetailQueryDto appGroupBuyOrderDetailQueryDto) {
        return ResultGenerator.success(orderService.appGroupBuyOrderDetail(appGroupBuyOrderDetailQueryDto));
    }

    @Override
    public Result<List<GroupBuyMemberVo>> groupMembers(GroupMembersQueryDto groupMembersQueryDto) {
        return ResultGenerator.success(groupBuyOrderService.listGroupMembers(groupMembersQueryDto));
    }

    @ApiOperation(value = "报名详情（报名订单）")
    @ApiResponse(response = AppOrderEnrollActiveDetail.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<AppOrderEnrollActiveDetail> appOrderEnrollActiveDetail(AppOrderEnrollActiveDetailDto appOrderEnrollActiveDetailDto) {
        return ResultGenerator.success(orderService.appOrderEnrollActiveDetail(appOrderEnrollActiveDetailDto));
    }

    @ApiOperation(value = "取消订单")
    @ApiImplicitParam(name = "CancelOrderDto", value = "实体", paramType = "body", dataType = "cancelOrderDto")
    @Override
    public Result<Boolean> cancelOrder(@RequestBody CancelOrderDto cancelOrderDto) {
        return ResultGenerator.success(orderService.cancelOrder(cancelOrderDto));
    }

    @ApiOperation(value = "确认参与")
    @ApiImplicitParam(name = "ConfirmJoinDto", value = "实体", paramType = "body", dataType = "confirmJoinDto")
    @Override
    public Result<Boolean> confirmJoin(@RequestBody ConfirmJoinDto confirmJoinDto) {
        return ResultGenerator.success(orderService.confirmJoin(confirmJoinDto));
    }

    @ApiOperation(value = "后台订单列表")
    @ApiImplicitParam(name = "adminOrderPageDto", value = "实体", paramType = "query", dataType = "AdminOrderPageDto")
    @ApiResponse(response = AdminOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<AdminOrderPageVo>> pageAdminOrder(AdminOrderPageDto adminOrderPageDto) {
        return ResultGenerator.success(orderService.pageAdminOrder(adminOrderPageDto));
    }

    @ApiOperation(value = "后台积分订单列表")
    @ApiImplicitParam(name = "adminPointsOrderPageDto", value = "实体", paramType = "query", dataType = "AdminPointsOrderPageDto")
    @ApiResponse(response = AdminPointsOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<AdminPointsOrderPageVo>> pageAdminPointsOrder(AdminPointsOrderPageDto adminPointsOrderPageDto) {
        return ResultGenerator.success(orderService.pageAdminPointsOrder(adminPointsOrderPageDto));
    }

    @ApiOperation(value = "后台积分订单列表: 导出")
    @ApiImplicitParam(name = "adminPointsOrderPageDto", value = "实体", paramType = "query", dataType = "AdminPointsOrderPageDto")
    @ApiResponse(response = AdminPointsOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<AdminPointsOrderPageVo>> listAdminPointsOrder(AdminPointsOrderPageDto adminPointsOrderPageDto) {
        return ResultGenerator.success(orderService.listAdminPointsOrder(adminPointsOrderPageDto));
    }

    @ApiOperation(value = "佣金订单列表")
    @ApiImplicitParam(name = "adminCommissionOrderPageDto", value = "实体", paramType = "query", dataType = "AdminCommissionOrderPageDto")
    @ApiResponse(response = AdminCommissionOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<AdminCommissionOrderPageVo>> pageAdminCommissionOrder(AdminCommissionOrderPageDto adminCommissionOrderPageDto) {
        return ResultGenerator.success(orderService.pageAdminCommissionOrder(adminCommissionOrderPageDto));
    }

    @ApiOperation(value = "佣金订单列表: 导出")
    @ApiImplicitParam(name = "adminCommissionOrderPageDto", value = "实体", paramType = "query", dataType = "AdminCommissionOrderPageDto")
    @ApiResponse(response = AdminCommissionOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<AdminCommissionOrderPageVo>> listAdminCommissionOrder(AdminCommissionOrderPageDto adminCommissionOrderPageDto) {
        return ResultGenerator.success(orderService.listAdminCommissionOrder(adminCommissionOrderPageDto));
    }

    @ApiOperation(value = "订单审核")
    @ApiImplicitParam(name = "orderAuditDto", value = "实体", paramType = "body", dataType = "orderAuditDto")
    @Override
    public Result<Void> businessOrderAudit(OrderAuditDto orderAuditDto) {
        orderService.businessOrderAudit(orderAuditDto);
        return ResultGenerator.success();
    }

    @ApiOperation(value = "订单批量审核")
    @ApiImplicitParam(name = "orderBatchAuditDto", value = "实体", paramType = "body", dataType = "orderBatchAuditDto")
    @Override
    public Result<String> businessOrderBatchAudit(OrderBatchAuditDto orderBatchAuditDto) {
        Integer successNum = 0, failedNum = 0;
        for (Long orderId : orderBatchAuditDto.getOrderIds()) {
            try {
                OrderAuditDto orderAuditDto = new OrderAuditDto();
                orderAuditDto.setOrderId(orderId);
                orderAuditDto.setAuditState(orderBatchAuditDto.getAuditState());
                orderAuditDto.setBusinessId(orderBatchAuditDto.getBusinessId());
                orderService.businessOrderAudit(orderAuditDto);
                successNum++;
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                failedNum++;
            }
        }
        return ResultGenerator.success(String.format("成功处理%d条，失败%d条", successNum, failedNum));
    }

    @ApiOperation(value = "团购订单详情")
    @ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", dataType = "String")
    @ApiResponse(response = AdminGroupOrderDetailVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<AdminGroupOrderDetailVo> detailAdminGroupOrder(Long orderId) {
        return ResultGenerator.success(orderService.detailAdminGroupOrder(orderId));
    }

    @ApiOperation(value = "报名订单详情")
    @ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", dataType = "String")
    @ApiResponse(response = AdminEnrollOrderDetailVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<AdminEnrollOrderDetailVo> detailAdminEnrollOrder(Long orderId) {
        return ResultGenerator.success(orderService.detailAdminEnrollOrder(orderId));
    }

    @ApiOperation(value = "订单详情")
    @ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", dataType = "String")
    @ApiResponse(response = AdminOrderDetailVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<AdminOrderDetailVo> detailAdminOrder(Long orderId) {
        return ResultGenerator.success(orderService.detailAdminOrder(orderId));
    }

    @ApiOperation(value = "获取某种类型订单的每个订单状态的订单个数")
    @ApiResponse(response = AdminOrderCountVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<AdminOrderCountVo>> getOrderCount(AdminOrderCountDto adminOrderCountDto) {
        return ResultGenerator.success(orderService.getOrderCount(adminOrderCountDto));
    }

    @ApiOperation(value = "商户分页团购/报名订单列表")
    @ApiResponse(response = MerchantOrderPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<MerchantOrderPageVo>> pageMerchantOrder(MerchantOrderPageDto merchantOrderPageDto) {
        return ResultGenerator.success(orderService.pageMerchantOrder(merchantOrderPageDto));
    }

    @ApiOperation(value = "商户订单导出列表")
    @ApiResponse(response = MerchantOrderExportVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<MerchantOrderExportVo>> exportMerchantOrder(MerchantOrderExportDto merchantOrderExportDto) {
        return ResultGenerator.success(orderService.exportMerchantOrder(merchantOrderExportDto));
    }

    @ApiOperation(value = "商户订单统计")
    @ApiResponse(response = MerchantOrderStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<MerchantOrderStatisticsVo> getMerchantOrderStatistics(MerchantOrderPageDto merchantOrderPageDto) {
        return ResultGenerator.success(orderService.getMerchantOrderStatistics(merchantOrderPageDto));
    }

    @ApiOperation(value = "商户团购/报名订单详情")
    @ApiResponse(response = MerchantOrderDetailVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<MerchantOrderDetailVo> detailMerchantOrder(Long orderItemId, Long merchantId) {
        return ResultGenerator.success(orderService.detailMerchantOrder(orderItemId, merchantId));
    }

    @ApiOperation(value = "核销确认(根据核销码获取订单确认数据)")
    @ApiResponse(response = MerchantVerifyConfirmVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<MerchantVerifyConfirmVo> getByVerifyCode(String verifyCode, Long merchantId) {
        return ResultGenerator.success(orderService.getByVerifyCode(verifyCode, merchantId));
    }

    @ApiOperation(value = "确认核销")
    @ApiImplicitParam(name = "merchantVerifyDto", value = "实体", paramType = "body", dataType = "MerchantVerifyDto")
    @Override
    public Result<Boolean> verify(@RequestBody MerchantVerifyDto merchantVerifyDto) {
        return ResultGenerator.success(orderService.verify(merchantVerifyDto));
    }

    @ApiOperation(value = "票付通出票通知")
    @ApiImplicitParam(name = "pftOrderTicketParam", value = "实体", paramType = "body", dataType = "PftOrderTicketParam")
    @Override
    public Result<Boolean> pftTicket(@RequestBody PftOrderTicketParam param) {
        return ResultGenerator.success(orderService.pftTicket(param));
    }

    @ApiOperation(value = "票付通门票参数下单预判")
    @Override
    public Result<Boolean> pftOrderPreCheck(String pftSupplier, String pftProduct, String pftTicket) {
        return ResultGenerator.success(true);// 先不验证门票是否可以下单，可能不在下单时间就麻烦
        //return ResultGenerator.success(pftService.orderPreCheck(pftSupplier, pftProduct, pftTicket));
    }

    @ApiOperation(value = "票付通核销")
    @ApiImplicitParam(name = "pftOrderCallBackParam", value = "实体", paramType = "body", dataType = "PftOrderCallBackParam")
    @Override
    public Result<Boolean> pftVerify(@RequestBody PftOrderCallBackParam param) {
        return ResultGenerator.success(orderService.pftVerify(param));
    }

    @ApiOperation(value = "核销记录列表")
    @ApiResponse(response = MerchantVerifyRecordPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<MerchantVerifyRecordPageVo>> pageVerifyRecord(MerchantVerifyRecordPageDto merchantVerifyRecordPageDto) {
        return ResultGenerator.success(orderService.pageVerifyRecord(merchantVerifyRecordPageDto));
    }

    @ApiOperation(value = "管理后台：核销记录, 分页")
    @ApiResponse(response = AdminVerifyRecordPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<AdminVerifyRecordPageVo>> pageAdminVerifyRecord(ActiveVerifyRecordQueryDto activeVerifyRecordQueryDto) {
        return ResultGenerator.success(orderService.pageAdminVerifyRecord(activeVerifyRecordQueryDto));
    }

    @ApiOperation(value = "管理后台：核销记录")
    @ApiResponse(response = AdminVerifyRecordPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<AdminVerifyRecordPageVo>> listAdminVerifyRecord(ActiveVerifyRecordQueryDto activeVerifyRecordQueryDto) {
        return ResultGenerator.success(orderService.listAdminVerifyRecord(activeVerifyRecordQueryDto));
    }

    @ApiOperation(value = "活动核销商户")
    @ApiResponse(response = ActiveVerifyMerchantVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<ActiveVerifyMerchantVo>> listVerifyMerchant(Long activeId) {
        return ResultGenerator.success(orderService.listVerifyMerchant(activeId));
    }

    @ApiOperation(value = "核销记录列表: 核销商品")
    @Override
    public Result<Page<MerchantVerifyGoodsPageVo>> pageVerifyGoods(MerchantVerifyGoodsPageDto merchantVerifyGoodsPageDto) {
        return ResultGenerator.success(orderService.pageVerifyGoods(merchantVerifyGoodsPageDto));
    }
    @ApiOperation(value = "核销记录列表: 商品核销记录明细")
    @Override
    public Result<Page<MerchantVerifyGoodsDetailPageVo>> pageVerifyGoodsDetail(MerchantVerifyGoodsDetailPageDto merchantVerifyGoodsDetailPageDto) {
        return ResultGenerator.success(orderService.pageVerifyGoodsDetail(merchantVerifyGoodsDetailPageDto));
    }

    @ApiOperation(value = "根据条件查询订单数据")
    @ApiResponse(response = OrderVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<OrderVo>> listByDto(OrderDto orderDto) {
        return ResultGenerator.success(orderService.listByDto(orderDto));
    }

    @ApiOperation(value = "用户在指定商家下单的数量，用于判断是否是商家新用户，能否使用新用户红包")
    @Override
    public Result<Integer> userBusinessOrderCount(Long userId, Long businessId) {
        return ResultGenerator.success(orderService.userBusinessOrderCount(userId, businessId));
    }

    @ApiOperation(value = "用户在指定活动下单的数量，用于判断是否限购")
    @Override
    public Result<Integer> userActiveOrderCount(Long userId, Long activeId) {
        return ResultGenerator.success(orderService.userActiveOrderCount(userId, activeId));
    }

    @ApiOperation(value = "消费延时订单消息")
    @Override
    public Result<Boolean> consumerOrderDelayMsg(String orderNo) {
        return ResultGenerator.success(orderService.consumerOrderDelayMsg(orderNo));
    }

    @ApiOperation(value = "系统取消支付（倒计时到了调用）")
    @Override
    public Result<Boolean> systemCancelPay(@RequestBody CancelPayDto cancelPayDto) {
        return ResultGenerator.success(orderService.systemCancelPay(cancelPayDto));
    }

    @ApiOperation(value = "查单（监听用户唤醒支付成功之后调用）")
    @Override
    public Result<Boolean> queryOrderPay(@RequestBody OrderPayQueryDto orderPayQueryDto) {
        return ResultGenerator.success(orderService.queryOrderPay(orderPayQueryDto));
    }

    @Override
    public Result<Boolean> toPay(@RequestBody OrderPayQueryDto orderPayQueryDto) {
        return ResultGenerator.success(orderService.toPay(orderPayQueryDto));
    }

    @ApiOperation(value = "消费订单退款消息")
    @Override
    public Result<Boolean> consumerOrderRefundMsg(Long orderRefundId) {
        return ResultGenerator.success(orderService.consumerOrderRefundMsg(orderRefundId));
    }

    @ApiOperation(value = "消费订单核销消息")
    @Override
    public Result<Boolean> consumerOrderVerifyMsg(Long orderId) {
        return ResultGenerator.success(orderService.consumerOrderVerifyMsg(orderId));
    }

    @ApiOperation(value = "根据活动id查询下单用户信息")
    @Override
    public Result<List<OrderAvatarVo>> listAvatarByDto(@RequestBody OrderDto orderDto) {
        return ResultGenerator.success(orderService.listAvatarByDto(orderDto));
    }

    @ApiOperation(value = "扫描待支付订单")
    @Override
    public Result<Boolean> scanWaitePayOrder() {
        return ResultGenerator.success(orderService.scanWaitePayOrder());
    }

    @ApiOperation(value = "扫描支付中订单")
    @Override
    public Result<Boolean> scanPayingOrder() {
        return ResultGenerator.success(orderService.scanPayingOrder());
    }

    @ApiOperation(value = "扫描待核销、核销中、已核销和活动核销时间已结束订单")
    @Override
    public Result<Boolean> scanEndVerifyOrder() {
        return ResultGenerator.success(orderService.scanEndVerifyOrder());
    }

    @ApiOperation(value = "扫描处理中的订单结算支付流水记录")
    @Override
    public Result<Boolean> scanOrderSettleBill() {
        return ResultGenerator.success(orderService.scanOrderSettleBill());
    }

    @ApiOperation(value = "子单结算任务")
    @Override
    public Result<Boolean> subOrderSettleTask() {
        orderSettleService.settleTask();
        return ResultGenerator.success();
    }

    @ApiOperation(value = "子订单结算积分[停用]")
    @Override
    public Result<Boolean> subOrderSettlePointsTask() {
        orderSettleService.subOrderSettlePointsTask();
        return ResultGenerator.success();
    }

    @ApiOperation(value = "下单用户积分结算")
    @Override
    public Result<Boolean> settleUserPointsTask() {
        orderSettleService.settleUserPointsTask();
        return ResultGenerator.success();
    }

    @ApiOperation(value = "经纪人积分结算")
    @Override
    public Result<Boolean> settleAgentPointsTask() {
        orderSettleService.settleAgentPointsTask();
        return ResultGenerator.success();
    }

    @ApiOperation(value = "扫描已核销的订单，更新商家与经纪人，商家与商户之间的统计信息")
    @Override
    public Result<Boolean> scanVerifiedOrder() {
        return ResultGenerator.success(orderService.scanVerifiedOrder());
    }

    @ApiOperation(value = "扫描已经转账成功的商户本金记录，生成商户本金手续费待转账记录")
    @Override
    public Result<Boolean> generateOrderSettleBillFeeTemp() {
        return ResultGenerator.success(orderService.generateOrderSettleBillFeeTemp());
    }

    @ApiOperation(value = "扫描处理中的订单结算手续费支付流水记录")
    @Override
    public Result<Boolean> scanOrderSettleBillFeeTemp() {
        return ResultGenerator.success(orderService.scanOrderSettleBillFeeTemp());
    }

    @Override
    public Result<List<AdminOrderPageVo>> listByWithdrawalId(Long withdrawalId) {
        return ResultGenerator.success(orderService.listOrderByWithdrawalId(withdrawalId));
    }

    @ApiOperation(value = "分销排行榜")
    @Override
    public Result<ActiveAgentRankVo> agentRank(Long activeId) {
        return ResultGenerator.success(orderService.agentRank(activeId));
    }

    @Override
    public Result<Page<AgentRankItemVo>> pageAgentRank(ActiveRankQueryDto activeRankQueryDto) {
        return ResultGenerator.success(orderService.pageAgentRank(activeRankQueryDto));
    }

    @Override
    public Result<List<AdminOrderPageVo>> listAdminOrder(AdminOrderPageDto adminOrderPageDto) {
        return ResultGenerator.success(orderService.listAdminOrder(adminOrderPageDto));
    }

    @Override
    public Result<List<String>> getLastAvatar(Integer count) {
        return ResultGenerator.success(orderService.getLastAvatar(count));
    }

    @Override
    public Result<Void> onActiveEnd(Long activeId) {
        orderService.onActiveEnd(activeId);
        return ResultGenerator.success();
    }

    @Override
    public Result<Void> noFullAutoRefund(Long activeId) {
        orderRefundService.noFullAutoRefund(activeId);
        return ResultGenerator.success();
    }

    @Override
    public Result<Void> calculateStepPriceRefund(Long activeId) {
        orderRefundService.calculateStepPriceRefund(activeId);
        return ResultGenerator.success();
    }

    @Override
    public Result<OrderEstimateCommissionVo> getOrderEstimateCommission(Long agentId) {
        return ResultGenerator.success(orderService.getOrderEstimateCommission(agentId));
    }

    @Override
    public Result<List<PendingGroupOrderVo>> listPendingGroupBuyOrders(Long activeId, Long userId) {
        return ResultGenerator.success(groupBuyOrderService.listPendingGroupBuyOrders(activeId, userId));
    }

    @Override
    public Result<List<GroupBuyOrderNumStatVo>> statisticsGroupOrderNumByActiveIds(List<Long> activeIds) {
        return ResultGenerator.success(groupBuyOrderService.statisticsGroupOrderNumByActiveIds(activeIds));
    }

    @Override
    public Result<Page<GroupBuyOrderPageVo>> pageGroupBuyOrders(GroupBuyOrderPageDto groupBuyOrderPageDto) {
        return ResultGenerator.success(groupBuyOrderService.page(groupBuyOrderPageDto));
    }

    @Override
    public Result<Long> createZeroGroupBuyOrder(CreateZeroGroupBuyOrderDto createZeroGroupBuyOrderDto) {
        Long groupBuyOrderItemId = groupBuyOrderService.createZeroGroupBuyOrder(createZeroGroupBuyOrderDto);
        return ResultGenerator.success(groupBuyOrderItemId);
    }

    @Override
    public Result<Void> scanExpiredGroupBuyOrders() {
        groupBuyOrderService.scanExpiredGroupBuyOrders();
        return ResultGenerator.success();
    }
}
